package com.binguo.api.controller;

import com.binguo.api.form.FaceForm;
import com.binguo.api.form.TokenForm;
import com.binguo.api.result.Result;
import com.binguo.api.result.ResultGenerator;
import com.binguo.entity.TokenVO;
import com.binguo.model.api.vo.CustomerVO;
import com.binguo.service.CustomerService;
import com.binguo.service.TokenService;
import com.qiniu.util.Auth;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import java.rmi.ServerError;

import static org.springframework.http.MediaType.APPLICATION_JSON_VALUE;


/**
 * Created by haibang on 18/5/7.
 */
@Api(tags = "收银端: token")
@RestController
@RequestMapping
public class TokenController {

    private static Logger logger = LoggerFactory.getLogger(TokenController.class);

    @Autowired
    TokenService tokenService;


    @PostMapping(value = "/api/token/refresh", produces = APPLICATION_JSON_VALUE)
    @ApiOperation(value = "刷新token", notes = "通过商户id,deviceId")
    public Result getCustomer(@RequestBody @Valid TokenForm form) {
        TokenVO vo = tokenService.refreshToken(form.getEmployeeId().toString(), form.getDeviceId());
        return ResultGenerator.genSuccessResult(vo);
    }



}
